package com.example.administrator.myapplication.guide;



import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;

import com.example.administrator.myapplication.R;

import java.util.ArrayList;
import java.util.List;

public class GuideActivity extends FragmentActivity {
    private ViewPager guide;
    private PagerAdapter pagerAdapter;
    private List<Fragment> fragments = new ArrayList<Fragment>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        guide = (ViewPager) findViewById(R.id.view_guide);

        for (int i = 0; i < 5; i++){
            GuideFragment fragment = new GuideFragment ();           //创建5个fragment分别装5个导航页
            Bundle bundle = new Bundle();
            bundle.putInt("index",i);                         //传递参数i，判断是第几个fragment
            fragment.setArguments (bundle);
            fragments.add(fragment);
        }

        pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments);
        guide.setAdapter(pagerAdapter);
    }
}
